//
// Created by baigui on 2021/10/3.
//

#ifndef SIMPLE_PLAYER_FFMPEGDEMUX_H
#define SIMPLE_PLAYER_FFMPEGDEMUX_H
#include "Demux.h"
#include <mediaStream.h>

extern "C" {
#include <libavformat/avformat.h>
}

class FFMPEGDemux : public Demux {
public:
    FFMPEGDemux(weak_ptr<MediaPlayer> player);
    ~FFMPEGDemux();

    bool Open(void *path) override;

    bool start() override;

    void handle(int , void *) override ;

    void requestbuffer() override;


private:
    MediaStream *mMediaStream;

    AVInputFormat  *mAVInputFormat;
    AVFormatContext *mAVFormatContext = nullptr;

    unsigned    i_tracks;

    int selectVideoTrack;

    int64_t     i_pcr;

    unsigned    i_ssa_order;

    int         i_attachments;

    bool        check_key_frame;

    FILE        *fp = nullptr;
};


#endif //SIMPLE_PLAYER_FFMPEGDEMUX_H
